package com.yishan.gulimall.springsecurity.exect;

import com.yishan.gulimall.springsecurity.config.R;
import lombok.extern.slf4j.Slf4j;
import org.springframework.validation.BindingResult;
import org.springframework.web.bind.MethodArgumentNotValidException;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.RestControllerAdvice;

import java.util.HashMap;
import java.util.Map;

@Slf4j
//@RestControllerAdvice(basePackages = "com.yishan.gulimall.springsecurity.controller")
public class GulimallExceptionControllerAdvice {

    @ExceptionHandler(value = Exception.class)
    public R handleException(Exception e) {
        log.error("数据校验出现问题{}, 异常类型{}", e.getMessage(), e.getClass());
        String message = e.getMessage();
        log.error(message);
        return R.error(message);
    }
}
